<%@ tag language="java" pageEncoding="UTF-8" body-content="scriptless" trimDirectiveWhitespaces="true"%>
<%@ attribute name="template" type="java.lang.String" required='true' description="选择使用哪个实例，可选值： country,ajax"%>
<%@ attribute name="id" type="java.lang.String" required='true' description="id"%>
<%@ attribute name="ajax" type="java.lang.String" required='false' description="仅当template为ajax时才有用，设置加载select数据的ajax，ajax返回的数据必须为json array，如：[{'id':'chengdu','text':'成都'},{'id':'nanchong','text':'南充'}]，你可以继续设置ajaxDataOptionId,ajaxDataText两个属性，来匹配你的json array数据格式"%>
<%@ attribute name="ajaxDataText" type="java.lang.String" required='false' description="ajax返回数据中，定义你的option的text的key值"%>
<%@ attribute name="ajaxDataId" type="java.lang.String" required='false' description="ajax返回数据中，定义你的option的value的key值"%>
<%@ attribute name="selectName" type="java.lang.String" required='false' description="select的name属性设置,仅template为ajax时有效"%>
<%@ attribute name="showSelectAll" type="java.lang.String" required='false' description="是否显示选择所有选项，仅template为ajax时有效，默认false"%>
<%@ attribute name="showSelectValue" type="java.lang.String" required='false' description="选择所有选项的值，仅showSelectAll为true时有效，默认为''"%>
<%@ attribute name="showSelectName" type="java.lang.String" required='false' description="选择所有选项的名称，仅showSelectAll为true时有效，默认为'全部'"%>
<%@ attribute name="className" type="java.lang.String" required="false" description="class属性值,仅template为ajax时有效"%>
<%@ attribute name="extraEvent" type="java.lang.String" required="false" description="定义ajax成功后的额外执行方法"%>
<div id='${id}'>
	<jsp:doBody/>
</div>
<script type="text/javascript">
(function(){
	this.event = "${extraEvent}"==""?undefined : eval("${extraEvent}");
	this.template = "${template}";
	this.id = "${id}";
	this.ajax = "${ajax}"=="" ? undefined: eval("${ajax}");
	this.ajaxDataText = "${ajaxDataText}"=="" ? "text": "${ajaxDataText}";
	this.ajaxDataId = "${ajaxDataId}"=="" ? "id": "${ajaxDataId}";
	this.showSelectAll = "${showSelectAll}" == ""?false:"${showSelectAll}"=="true";
	this.showSelectValue = "${showSelectValue}"==""?"":"${showSelectValue}";
	this.showSelectName = "${showSelectName}"==""?"全部":"${showSelectName}";
	this.selectName = "${selectName}";
	this.className = "${className}";
	this.options = {
		'ajax':this.ajax,
		'ajaxDataText':this.ajaxDataText,
		'ajaxDataId':this.ajaxDataId,
		'event':this.event,
		'showSelectAll':this.showSelectAll,
		'showSelectValue':this.showSelectValue,
		'showSelectName':this.showSelectName,
		'selectName':this.selectName,
		'className':this.className
	};
	new ComplexSelect(this.id,this.template,this.options);
})();
</script>